import 'dart:ui';

import 'package:flutter/material.dart';

import './global/bridage.dart';


void main() => runApp(_widgetForRoute(window.defaultRouteName));

Widget _widgetForRoute(String route){
  switch (route){
    case 'myApp':
      return SampleApp();
    case 'home':
      return Container();
    default:
      return SampleApp();
  }

}

class SampleApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyFadeTest(title: 'Fade Demo'),
    );
  }
}

class MyFadeTest extends StatefulWidget {
  MyFadeTest({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyFadeTest createState() => _MyFadeTest();
}

class _MyFadeTest extends State<MyFadeTest> with TickerProviderStateMixin {
  String title1 = "   Flutter   View   ";
  @override
  void initState() {

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // Bridge.setMessageHandle();
    Bridge().setUserInfoMessageHandle();
    // Bridge.eventChannel();
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: InkWell(
        child:Container(
          width:375,
          height: 100,
          color:Colors.red,
          child:Text(title1,
            style: TextStyle(
              fontSize: 30,
            ),
          )
        ),
        onTap: (){
          Navigator.push(context, MaterialPageRoute( builder:(context) => MyFadeTest(title: 'Fade Demo')));
          Bridge().callRefreshUserInfomethodChannelMethod('callRefreshUserInfomethodChannelMethod');
          // Bridge.callMethod("flutter call native paramas");
          // Future result = Bridge.setMethodHandle();
          // print('native call flutter $result');
          // Bridge.eventChannel();
          // Bridge().sendUserInfoMessage('sendUserInfoMessage');
        },
      )
    );
  }
}

